home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / btchroom.zip / BTCHROOM.ASM next >
Assembly Source File  |  1990-12-15  |  7KB  |  240 lines

  1.     .XLIST
  2.     .XCREF
  3.     PAGE    84,127        ;FOR MINI PRINT
  4.     TITLE    BTCHROOM.ASM
  5. COMMENT ~
  6.  .LIST ;******************************************** BTCHROOM.ASM
  7. ;          MAKE ROOM FOR COMMAND.COM'S BATCH FILE BLOCKS        *
  8. ;****************************************************************
  9. ;
  10. ;                            12/15/90
  11. ;
  12.    A program which remains resident with 512 bytes after creating a
  13. file 'BTCHRLSE.COM' which when run releases 'BTCHROOM's resident
  14. code for use by COMMAND.COM for it's 'BATCH Information Block'.
  15.    When COMMAND.COM executes a batch file it 1) opens the file,
  16. 2) reads a line, 3) closes the file after recording the file's name
  17. and location of the last line read and 4) then executes the line.
  18. This information is kept in RAM in what I will call a 'Batch File
  19. Information' block, part of the DOS memory chain which I will call
  20. a 'Batch File Information Block'.
  21.    When running any batch file COMMAND.COM uses the 1st open memory
  22. block for it's 'Batch File Information Block' if there is no free room
  23. it puts this block at the top of free ram.
  24.    When running a batch file which releases TSR's from memory using
  25. such programs as 'MARK/RELEASE', if this block is at the top of free
  26. ram the release program kills this 'information' block causing
  27. COMMAND.COM to hang when it can't find it's batch file information.
  28.    Running 'BTCHROOM' in your AUTOEXEC.BAT file before the 1st release
  29. point leaves it resident with a size of 512 bytes and creates the file
  30. 'BTCHRLSE.COM'.
  31.    After all the TSR's are loaded, run the new file 'BTCHRLSE', again
  32. from your AUTOEXEC.BAT, which will release 'BTCHROOM' leaving a 512K
  33. 'hole' for COMMAND.COM to use which will not be lost when a batch file
  34. using the 'RELEASE' portion of 'MARK/RELEASE' is run and will erase
  35. itself from the disk.
  36. ;
  37. ~ ; COMMENT
  38. ;****************************************************************
  39. ;
  40. LF    EQU    0AH
  41. CR    EQU    0DH
  42. ;
  43. S0000    SEGMENT
  44.     ASSUME DS:S0000, SS:S0000 ,CS:S0000 ,ES:S0000
  45.     ORG    $+0100H
  46. ;
  47. ;****************************************************************
  48. ;
  49. ; START
  50. ;
  51. L0100    PROC    NEAR
  52. ;
  53.     MOV    BX,1000H        ;FREE ALL BUT 64K
  54.     MOV    AH,4AH
  55.     INT    21H            ;FREE ALLOCATED MEMORY
  56.     MOV    AX,DS:[002CH]        ;POINT TO OUR ENVIRONMENT
  57.     MOV    WORD PTR BRENVT,AX    ;FOR BTCHRLSE
  58.     MOV    AX,CS            ;GET OUR SEGMENT
  59.     MOV    WORD PTR BRCODE,AX    ;FOR BTCHRLSE
  60.     MOV    SI,0081H
  61.     MOV    CL,BYTE PTR [SI-1]    ;GET COUNT
  62.     XOR    CH,CH
  63.     JCXZ    L0119            ;NO INPUT, make BTCHRLSE
  64.     MOV    DI,SI
  65.     CLD
  66.     MOV    AL,'?'
  67.     REPNZ    SCASB
  68.     JNZ    L0119
  69. ;
  70. ;    GIVE HELP
  71. ;
  72. HELP:    MOV    DX,OFFSET HLPMSG
  73.     MOV    AH,09
  74.     INT    21H
  75.     INT    20H
  76. ;
  77. ;----------------------------------------------------------------
  78. ;
  79. HLPMSG    LABEL NEAR
  80.  DB CR,LF,'BTCHROOM.COM              '
  81.  DB 'Community Business Systems                   12/15/90'
  82.  DB CR,LF,LF
  83.  DB "Creates a 512 byte block of free ram for COMMAND.COM's "
  84.  DB "batch file block so that"
  85.  DB CR,LF
  86.  DB "it will not 'loose itself' when releasing memory using "
  87.  DB "a TSR release program.  Run 'BTCHROOM' before any 'RELEASE' "
  88.  DB "programs in your"
  89.  DB CR,LF
  90.  DB "'AUTOEXEC.BAT' and then run 'BTCHRLSE' after all removable "
  91.  DB "TSR's are loaded."
  92.  DB CR,LF,'$'
  93. ;
  94. ;----------------------------------------------------------------
  95. ;
  96. ; PUT 'BTCHRLSE.COM' IN OUR ENVIRONMENT
  97. ;
  98. L0119:    PUSH    ES
  99.      MOV    AX,CS:002CH        ;POINT TO OUR ENVIRONMENT
  100.      MOV    ES,AX
  101.      MOV    CX,OFFSET BADFIL
  102.      MOV    SI,OFFSET FNTSTR
  103.      SUB    CX,SI            ;LGT OF STR
  104.      XOR    DI,DI            ;ES:DI->OUR ENVIRONMENT
  105.      MOV    AX,DI
  106.      STOSW                ;STO 0000
  107.      INC    AX
  108.      STOSW                ;STO 0001
  109.      REP    MOVSB            ;PUT STRING IN ENVIRONMENT
  110.     POP    ES     
  111.     MOV    DX,OFFSET FNTSTR
  112.     MOV    AX,4300H        ;GET FILE ATTR
  113.     INT    21H
  114.     TEST    CL,0110B        ;HIDDEN OR SYSTEM FILE?
  115.     JNZ    BADFIL            ;YES
  116.     MOV    AX,4301H        ;NO, SET FILE ATTR
  117.     MOV    CX,0000            ;TO R/W
  118.     INT    21H
  119.     MOV    AH,3CH            ;CREATE FILE @ DX
  120.     MOV    CX,0020H        ;ATTR
  121.     INT    21H
  122.     JB    L0152            ;ERROR
  123.     MOV    BX,AX
  124.     MOV    AH,40H            ;WRITE TO FILE
  125.     MOV    DX,OFFSET RLSPGM        ;POINT TO FILE
  126.     MOV    CX,OFFSET ENDRLS-OFFSET RLSPGM    ;LENGTH TO WRITE
  127.     INT    21H                ;WRITE IT
  128.     MOV    AH,3EH            ;CLOSE IT
  129.     INT    21H
  130.     MOV    DX,OFFSET INSTLMS
  131.     MOV    AH,09
  132.     INT    21H
  133.     MOV    DX,0032            ;RESERVE .5K
  134.     MOV    AX,3100H
  135.     INT    21H            ; LEAVE BATCH FILE ROOM
  136. ;
  137. ;----------------------------------------------------------------
  138. ;
  139. BDFLMS    DB CR,LF,"*** HIDDEN OR SYSTEM FILE, can't overwrite ***"
  140.     DB CR,LF,'$'
  141. INSTLMS    DB "*** BTCHROOM installed, run 'BTCHRLSE' ***",CR,LF,'$'
  142. ;
  143. FNTSTR    DB 'BTCHRLSE.COM',00            ; Name for file to create
  144. ;
  145. ;    HIDDEN OR SYSTEM FILE, NO CAN DO
  146. ;
  147. BADFIL:    POP    DX
  148.     MOV    DX,OFFSET BDFLMS
  149.     MOV    AH,09
  150.     INT    21H
  151. ;
  152. ;****************************************************************
  153. ;
  154. ; FILE ERROR, RING BELL
  155. ;
  156. L0152:    MOV    AX,0E07H        ;TTY OUT & BELL
  157.     INT    10H
  158.     INT    20H            ;BACK TO DOS
  159. ;
  160. L0100    ENDP
  161. ;
  162. ;****************************************************************
  163. ; USER SUPPLIED FN.T START, RUNS TO RELEASE MEMORY
  164. ;****************************************************************
  165. ;
  166. RLSPGM    PROC    NEAR
  167. ;
  168.     MOV    BX,1000H        ;FREE ALL BUT 64K
  169.     MOV    AH,4AH
  170.     INT    21H            ;FREE ALLOCATED MEMORY
  171. BRENVT    EQU    $+1            ;BTCHROOM's environment
  172.     MOV    DX,0000            ;Get BTCHROOM'S environmene segment
  173.     MOV    ES,DX            ;To ES
  174.     MOV    AH,49H            ;Free it
  175.     INT    21H
  176. BRCODE    EQU    $+1            ;BTCHROOM's code
  177.     MOV    DX,0000            ;GET BTCHROOM'S code segment
  178.     MOV    ES,DX
  179.     MOV    AH,49H            ;Free it
  180.     INT    21H
  181. ; Now erase us
  182.     MOV    ES,CS:[002CH]        ;POINT TO OUR ENVIRONMENT
  183.     CALL    FNDNAM            ;FIND OUR NAME
  184.     MOV    DX,DI
  185.     PUSH    ES
  186.     POP    DS            ;DS:DX->OUR FN.T
  187.     MOV    AX,4300H        ;GET FILE ATTR
  188.     INT    21H
  189.     TEST    CL,0110B        ;ARE WE HIDDEN OR SYSTEM?
  190.     JNZ    NOKILL            ;YES
  191.     MOV    DX,DI
  192.     MOV    AX,4301H        ;NO, SET FILE ATTR
  193.     MOV    CX,0000            ;TO R/W
  194.     INT    21H
  195.     MOV    DX,DI
  196.     MOV    AH,41H            ;AND DELETE US
  197.     INT    21H
  198. ;
  199. ;    WE ARE HIDDEN OR SYSTEM FOR SOME REASON, DON'T ERASE
  200. ;
  201. NOKILL:    PUSH    CS
  202.     POP    DS
  203.     MOV    DX,OFFSET DONMSG+100H-OFFSET RLSPGM    ;GET MSG OFST FRM START
  204.     MOV    AH,09
  205.     INT    21H
  206.     INT    20H
  207. ;
  208. ;****************************************************************
  209. ;
  210. ;    POINT ES:DI->THE FILENAME IN THE ENVIRONMENT @ CS:
  211. ;
  212. FNDNAM    PROC NEAR
  213. ;
  214.     XOR    DI,DI
  215.     MOV    AX,DI
  216.     MOV    CX,0FFFFH
  217. ;
  218. ;    LOOP TO OUR NAME IN OUR ENVIRONMENT TO ERASE US
  219. ;
  220. FNDNM1:    REPNZ    SCASB            ;FIND A NULL
  221.     SCASB                ;2ND NULL?
  222.     JNZ    FNDNM1            ;NO
  223.     ADD    DI,0002            ;YES, ES:DI->OUR NAME IN ENVIRONMENT
  224.     RET
  225. FNDNAM    ENDP
  226. ;
  227. ;****************************************************************
  228. ;
  229. DONMSG    DB CR,LF
  230.     DB '           Removing: BTCHROOM',CR,LF
  231.     DB '  *** .5K ROOM MADE FOR BATCH FILE BLOCKS ***',CR,LF,'$'
  232. ;
  233. RLSPGM    ENDP
  234. ;
  235. ;****************************************************************
  236. ;
  237. ENDRLS    EQU    $
  238.     S0000    ENDS
  239.     END    L0100
  240.